﻿//  --------------------------------
//  Copyright (c) PK Logix LLC. All rights reserved.
//  This source code is made available under the terms of the GNU General Public License version 2 (GPLv2)
//  http://www.codeplex.com/mvcclubsite/license
//  ---------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MVCClubSite.IDAL;
using MVCClubSite.Model;

namespace MVCClubSite.TestDAL
{
    public class TestAnnouncementsData : IAnnouncements 
    {
        IList<Announcement> _announcementList;

        public TestAnnouncementsData()
        {
            _announcementList = new List<Announcement>();

            for (int i = 1; i <= 5; i++)
            {
                Announcement a = new Announcement();
                a.ID = i;
                a.Title = "Title " + i;
                a.Description = "Description " + i;
                a.ImageID = 0;
                a.AlbumID = 0;

                _announcementList.Add(a);
            }
        }

        public IQueryable<Announcement> GetAllAnnouncements()
        {
            return _announcementList.AsQueryable<Announcement>();
        }

        public IQueryable<Announcement> GetVisibleAnnouncements()
        {
            return (from a in _announcementList
                    where a.AnnouncementDate <= DateTime.Now
                    select a).AsQueryable<Announcement>();
        }

        public IQueryable<Announcement> GetRecentAnnouncements(int count)
        {
            return (from a in _announcementList
                    where a.AnnouncementDate <= DateTime.Now
                    select a).Take(count).AsQueryable<Announcement>();
        }

        public Announcement GetAnnouncementByID(int id)
        {
            return (from a in _announcementList
                    where a.ID == id
                    select new Announcement
                    {
                        ID = a.ID,
                        Title = a.Title,
                        Description = a.Description,
                        ImageID = a.ImageID,
                        AlbumID = a.AlbumID,
                        Author = a.Author,
                        AnnouncementDate = a.AnnouncementDate,
                    }).SingleOrDefault();
        }

        public void Save(Announcement announcement)
        {
            throw new NotImplementedException();
        }

        public void Delete(int id)
        {
            throw new NotImplementedException();
        }
    }
}
